<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>异步加载js</title>
</head>
<body>

</body>
<script type="text/javascript">
    // 按需加载外部tools js函数
    function loadScript(url, callback) {
        var script = document.createElement('script');
        script.type = "text/javascript";
        if (script.readyState) {
            script.onreadystatechange = function() {
                // ie
                if (script.readyState == "complete" || script.readyState == loaded) {
                    tools[callback]();
                }
            }
        }else{
            script.onload = function() {
                tools[callback]();
            }
        }
        script.src = url;
        document.head.appendChild(script);
    }

    loadScript('tools.js', 'init');
</script>
</html>
